<template>
  <div class="cont">
    <CompA />
    <CompB />
    <CompC />
    <div v-for="item in cateList" :key="item.objectId">
      {{ item.name }}
    </div>
  </div>
</template>

<script>
import CompA from "./comp-a.vue";
import CompB from "./comp-b.vue";
import CompC from "./comp-c.vue";
import { mapActions } from "vuex";
export default {
  components: {
    CompA,
    CompB,
    CompC,
  },
  computed: {
    cateList() {
      return this.$store.state.category.cateList;
    },
  },
  methods: {
    ...mapActions({
      initCate: "category/getCategoryAct",
    }),
  },
  created() {
    // 方法1：直接触发action
    // this.$store.dispatch("category/getCategoryAct"); //触发actions方法
    // 方法2：通过辅助函数触发action
    this.initCate();
  },
};
</script>

<style lang="scss" scoped>
.cont {
  display: flex;
}
</style>
